Add a Folder to a Folder Search List
Source code
'************************************************************************************************************************
'Description:
'
'This example opens UFT One and uses the Folders collection to configure
'the search paths that are used to resolve relative paths.
'
'Assumptions:
'There is no unsaved test currently open in UFT One.
'For more information, see the example for the Test.SaveAs method.
'************************************************************************************************************************

Dim qtApp 'As QuickTest.Application ' Declare the Application object variable
Dim strPath
Dim lngPosition

' Open UFT One
Set qtApp = CreateObject("QuickTest.Application") ' Create the Application object
qtApp.Launch ' Start UFT One
qtApp.Visible = True ' Make the UFT One application visible

' Open a test
qtApp.Open "C:\Tests\Test1", True, False ' Open a test in a read-only mode

' Locate "Folder1" and if it's not in the collection - add it
strPath = qtApp.Folders.Locate("..\..\Folders\Folder1")
' Locate the "Folder1" folder

' If returned empty string, then we cannot locate the absolute path, so there is nothing to do
If strPath <> "" Then
  If qtApp.Folders.Find(strPath) = -1 Then ' If the folder is not found in the collection
    qtApp.Folders.Add strPath, 1 ' Add the folder to the collection
  End If
End If

Set qtApp = Nothing ' Release the Application object